/**
 * Copyright (C), 2012-2018, 联奕科技有限公司
 * FileName: QQAutoConfig
 * Author:   石贵武
 * Date:     2018\3\14 0014 14:47
 * Description: 配置类
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.zhoudongxiu.security.core.social.qq.config;


import com.zhoudongxiu.security.core.properties.QQProperties;
import com.zhoudongxiu.security.core.properties.SecurityProperties;
import com.zhoudongxiu.security.core.social.qq.connect.QQConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.social.SocialAutoConfigurerAdapter;
import org.springframework.context.annotation.Configuration;
import org.springframework.social.connect.ConnectionFactory;

/**
 * 〈一句话功能简述〉<br>
 * 〈配置类〉
 *
 * @author 石贵武
 * @create 2018\3\14 0014
 * @since 1.0.0
 */
@ConditionalOnProperty(prefix = "zhoudongxiu.security.social.qq", name = "app-id")
@Configuration
public class QQAutoConfig extends SocialAutoConfigurerAdapter {


    @Autowired
    private SecurityProperties securityProperties;


    @Override
    protected ConnectionFactory<?> createConnectionFactory() {

        QQProperties qqConfig = securityProperties.getSocial().getQq();

        return new QQConnectionFactory(qqConfig.getProviderId(), qqConfig.getQq().getAppId(), qqConfig.getAppSecret());
    }
}